<?php include TMPL_PATH.'public/header.phtml';?>
<link rel="stylesheet" type="text/css" href="/statics/js/calendar/jscal2.css"/>
<link rel="stylesheet" type="text/css" href="/statics/js/calendar/border-radius.css"/>
<link rel="stylesheet" type="text/css" href="/statics/js/calendar/win2k.css"/>
<script type="text/javascript" src="/statics/js/calendar/calendar.js"></script>
<script type="text/javascript" src="/statics/js/calendar/lang/zh-cn.js"></script>

    <!-- <div class="order_th">商品信息</div> -->
        <div id="div_setting_2" class="contentList division pad-10">
        <div class="table-grid" style="border: 1px solid #efefef;">
            <table width="100%" cellspacing="0" cellpadding="2" border="0" class="gridlist" id="order_items"> 
                <thead> 
                    <tr>
                     <th style="width:10%;">货号</th> 
                     <th style="width:20%;">商品名称</th>
                     <th style="width:30%;">身形数据</th>
                     <th style="width:5%;">设计师</th>
                     <th style="width:5%;">价格</th> 
                     <th style="width:5%;">购买数量</th> 
                     <th style="width:5%;">小计</th> 
                     <th style="width:20%;">操作</th>			 
                    </tr> 
                </thead> 
                <tbody>

                <?php 
                if(isset($product) && $product):
                    foreach ($product as $pkey => $product):
                ?>
                <?php 
                    if($product['product_name']){
                        $where_name = array('product_id'=>$product['product_id'],'language_id'=>6);
                        $product_items = D('product_items')->where($where_name)->find();
                    }
                    $suppliers = M('suppliers')->where(array('suppliers_id'=>$product['suppliers_id']))->find();
                    if($suppliers){
                        $product['attr'] .= ' ,面料编号: '.$suppliers['suppliers_name']; 
                    }
                ?>

                    <tr> 
                        <td align="center"><?php echo $product['product_sn'];?><br /><?php echo $product['order_id'].'-'.$product['id'];?></td> 
                        <td align="center" style="word-break:break-all"><?php echo $product_items['name'];if($product['attr']){echo ' ( '. $product['attr'] . ' )';}?>
                        <?php 
						    $ipcount = M('ipcount')->field('custom,more_option')->where(array('orderitemid'=>$product['id']))->find();
							if($ipcount){
							   $custom_str  = $ipcount['custom']      == 1 ? '现货' :'定制';
							   $option_str  = $ipcount['more_option'] == 1 ? '是' :'否';
							   echo "<hr />";
							   echo "定制方式:".$custom_str;
							   echo "<br />";
							   echo "more_option:".$option_str;
							}
						?>
                        <?php
                            if($product['pants_qty'] > 0){
							   echo "<hr />";
							   echo "加同款单裤:".$product['pants_qty']."条 (".$product['pants_price']."X".$product['pants_qty'].")";						    
							}
						?>
                        </td> 
                        <td>
                        <?php if(isset($product['measure_data']) && $product['measure_data'] ):?>
                        <div class="contentList division pad-10 ">
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" class="table_form"> 
                            <tbody>
                            <tr><td colspan="2">身形数据所有人：</td><td><?php echo $product['measure_data']['measure_name']?></td>
                               <th colspan="2">量体方式：</th><td colspan="2">
                                    <?php 
                                    $status = $product['measure_data']['m_status'];
                                    if($status == 1){
                                        echo '量尺量体';
                                    }else if($status == 2){
                                        echo '免量体';
                                    }else if($status == 3){
                                        echo '拍照量体';
                                    }else if($status == 4){
                                        echo '量尺并拍照';
                                    }
                                    ?>
                                </td><tr>
                            <tr>
                                <?php 
                                    $data = $product['measure_data']['measure_data'];
                                    echo "<tr><th style='width:50px'>年龄</th><td>{$product['measure_data']['age']}</td>"
                                    . "<th >身高</th><td>{$product['measure_data']['height']}cm</td>"
                                    . "<th >体重</th><td>{$product['measure_data']['weight']}kg</td>"
                                    . "<th style='width:50px'>上衣尺码</th><td>{$product['measure_data']['clothes_size']}</td>"
                                    . "<th style='width:50px'>裤子尺码</th><td>{$product['measure_data']['pants_size']}</td></tr>";
                                    if($status == 2){
                                        echo "<tr><td>chest</td><td>{$data['chest']['type']}</td><td>stomach</td><td>{$data['stomach']['type']}</td><td>shoulder</td><td>{$data['shoulder']['type']}</td><td>posture</td><td>{$data['posture']['type']}</td><td></td><td></td></tr>";
                                    }
                                    if(($status == 3 || $status == 4) || ($product['measure_data']['front_img'] && $product['measure_data']['side_img'])){
                                       echo  "<tr><td></td><td colspan='4'><img width=200 src='{$product['measure_data']['front_img']}'></td><td></td><td colspan='4'><img width=200 src='{$product['measure_data']['side_img']}'></td></tr>";
                                    }
                                    if($status == 1 || $status == 4){
                                    $i=0;
                                    foreach ($data as $key => $val){
                                        if($i==0 || $i%5==0){
                                            echo '<tr>';
                                        }
                                        if(in_array($key,array('age','weight','height'))){
                                            continue;
                                        }
                                        echo '<th style="width:50px">'. $key.'</th><td>';
                                        if(is_array($val)){
                                            foreach ($val as $key2 => $val2){
                                                if($key2=='type'){
                                                    echo $val2.'&nbsp;';
                                                }else{
                                                    echo $val2.$key2.' ';
                                                }
                                            }
                                        }else{
                                            echo  $val;
                                        }
                                        echo  '</td>';
                                        if(($i+1)%5==0){
                                            echo '</tr>';
                                        }
                                        $i++;
                                        }
                                    }
                                   ?>
                         </tbody>
                        </table>
                        </div>
                        <?php endif;?>
                        </td>
                        <td align="center"><?php echo $product['designer_id'] ? $designerList[$product['designer_id']]['username'] : '--';?></td> 
                        <td align="center"><?php echo $product['pay_price'];?></td> 
                        <td align="center"><?php echo $product['qty'];?></td> 
                        <td align="center"><?php echo $product['total_amount'];?></td> 

                        <td align="center">
                            <?php echo $product['measure_data']['measure_name']?>
                            <br />
                            <?php if($product['custom_type'] && $product['model_id'] != 25):?>
                                <a href="javascript:openwinx('<?php echo U('order/set_measure', 'order_item_id='.$product['id']),'&uid='.$product['measure_id'];?>','set_measure');">
                                    <?php if(!$product['isset_size_measure']){ ?>
                                        设置身型
                                    <?php }else{ ?>
                                        已设置身型<br />点此重设
                                        
                                    <?php }; ?>
                                </a>
                                <?php if($product['isset_size_measure']){ ?>
                                <br /> 
                                <a href="javascript:openwinx('<?php echo U('order/order_print_figure_god', 'order_item_id='.$product['id']),'&uid='.$product['measure_id'];?>','order_print<?php echo rand(1000,9999);?>');">打印</a>
									<br /> 
									<?php if(!$product['inventory']){ ?>
                                        <a href="javascript:openwinx('<?php echo U('Suppliers/set_inventory', 'order_item_id='.$product['id']);?>','set_inventory<?php echo rand(1000,9999);?>',600,500);">设置用料</a>                                
                                    <?php }else{ ?>
                                        已设用料
									<?php }; ?>
								<?php }; ?>
                            <?php endif; ?>
                            <?php if($product['model_id'] == 25):?>
                                <a href="<?php echo U('order/shoesWord', 'order_item_id='.$product['id']); ?>">导出word</a><br />
                                <a href="javascript:openwinx('<?php echo U('order/order_print_figure_god', 'order_item_id='.$product['id']),'&uid='.$product['measure_id'];?>','order_print<?php echo rand(1000,9999);?>');">打印</a>							
							<?php endif;?>
                        </td>
                        </tr>
                <?php 
                    endforeach;
                endif;
                ?>
                
                
                </tbody> 
            </table>	
        </div></div>
</body>
</html>
